package com.hqj.demo.test;

import com.hqj.demo.entity.Teacher;
import com.hqj.demo.service.TeacherService;
import com.hqj.demo.service.TeacherServiceI;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;

/**
 * spring IOC练习
 * 写一个Teacher实体，有属性String name,String sex,Double height
 * 提供get/set方法，构造方法
 *
 * Dao,实现对返回几个老师信息List<Teacher>
 * Service,实现对返回几个老师信息List<Teacher>
 * 测试类，调用方法，获取集合，输出老师信息
 * 配置文件spring01.xml
 *
 */
public class Exercise01 {
    public static void main(String[] args) {

        //加载spring的配置文件
        ApplicationContext ac =
                new ClassPathXmlApplicationContext("com/hqj/demo/spring01.xml");

        //通过id读取容器的bean
        TeacherService ts = (TeacherServiceI)ac.getBean("tsi");
        List<Teacher> list = ts.findTea();
        for(Teacher t:list){
            System.out.println(t);
        }
    }
}
